package com.pkk.alert.common.constant;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Optional;

/**
 * @description: redis的key常量
 * @author: peikunkun
 * @create: 2019-07-06 10:54
 **/
public class RedisKeyConstant {


  /**
   * 飞鸽使用的账号id
   */
  public static final String KEY_FEIGE_USE_ACCOUNT = "key_feige_use_account_";

  /**
   * 获取飞鸽的账号的redis的key
   *
   * @param accountId
   * @return
   */
  public static final String getKeyFeigeUseAccount(Long accountId) {
    Optional.ofNullable(accountId).orElseThrow(() -> new IllegalArgumentException("账号id为空,无法操作redis"));
    String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMM"));
    StringBuffer stringBuffer = new StringBuffer(KEY_FEIGE_USE_ACCOUNT);
    stringBuffer.append(format);
    stringBuffer.append("_");
    stringBuffer.append(accountId);
    return stringBuffer.toString();
  }
}
